import { LvUploadFile, LvUploadFiles } from '@/decorator/upload.decorator'
import { Controller, Post, UploadedFile, UploadedFiles } from '@nestjs/common'
import { UploadService } from './upload.service'
import { ApiTags, ApiOperation } from '@nestjs/swagger'

@ApiTags('上传')
@Controller('upload')
export class UploadController {
  constructor(private readonly uploadService: UploadService) {}

  @ApiOperation({ summary: `上传图片接口`, description: '上传图片返回图片信息' })
  @Post('image')
  @LvUploadFile('file', ['image', 'video'], 10)
  uploadIamge(@UploadedFile() file: Express.Multer.File) {
    return file
  }

  @ApiOperation({ summary: `多文件上传图片接口`, description: '多文件上传图片返回图片信息' })
  @Post('images')
  @LvUploadFiles('files', 6, ['image', 'video'], 10)
  uploadImages(@UploadedFiles() files: Array<Express.Multer.File>) {
    return files
  }
}
